/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nationsim.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JPanel;
import nationsim.api.Constants;
import nationsim.components.nation.Nation;
import nationsim.components.nation.NationStateValues;

/**
 *  The panel that will display all the output for the game.
 * @author CJ
 */
public class DisplayPanel extends JPanel {

    protected Nation playerNation;
    protected int year;

    public DisplayPanel(){
        this.year = Constants.STARTING_YEAR - 1;
        this.initPanel();
    }

    protected void initPanel(){
        this.setPreferredSize(new Dimension(Constants.DIS_PANEL_WIDTH, Constants.DIS_PANEL_HEIGHT));
        this.setFocusable(true);
    }

    public void refresh(Nation[] external, Nation playerNation){
        this.playerNation = playerNation;
        year++;
        repaint();
    }

    public void paintComponent(Graphics g){
        g.setColor(Color.GRAY);
        g.fillRect(0, 0, Constants.DIS_PANEL_WIDTH, Constants.DIS_PANEL_HEIGHT);
        g.setColor(Color.black);
        g.drawString("Year: " + this.year, 0, 15);
        if(this.playerNation != null){
            //Draw Nation Stats
            this.drawPlayerNationState(g);
        }
    }

    protected void drawPlayerNationState(Graphics g){
        g.setColor(Color.black);
        g.drawString("Total Money $: " + this.playerNation.getState().getInstanceValue(NationStateValues.FEDERAL_TREASURY).toString()
                , 0, 30);
        g.drawString("Total Citizens in Billions: " + this.playerNation.getState().getInstanceValue(NationStateValues.NUM_CITIZENS_BILLIONS).toString()
                , 0, 45);
        g.drawString("Federal Income Tax: " + this.playerNation.getState().getInstanceValue(NationStateValues.FEDERAL_INCOME_TAX)
                , 0, 60);
    }
}
